<?php $this->import('Header') ?>
	<div class="row-fluid">
		<div class="btn-toolbar">
			<a href="/Work/Edit" class="btn btn-primary"><i class="icon-plus"></i> 添加作品</a>
		</div>
		<div class="well">
			<form>
				状态：
				<select name="status">
					<option value="all">全部</option>
					<option value="1" <?php echo $condition['status'] == '1' ? ' selected' : ''; ?> >显示</option>
					<option value="0" <?php echo $condition['status'] == '0' ? ' selected' : ''; ?> >隐藏</option>
				</select>
				类型：
				<select name="type">
					<option value="all">全部</option>
					<option value="1" <?php echo $condition['type'] == 1 ? ' selected' : ''; ?> >首页作品</option>
					<option value="2" <?php echo $condition['type'] == 2 ? ' selected' : ''; ?> >汇总攻略</option>
				</select>
				<button class="btn">搜索</button>
			</form>
			<div class="tab-content">
				<table class="table">
					<tr>
						<td>Id</td>
						<td>作品名称</td>
						<td>状态</td>
						<td>类型</td>
						<td>添加时间</td>
						<td>修改时间</td>
						<td style="width: 160px;">操作</td>
					</tr>
					<?php foreach ($works as $arr) { ?>
					<tr>
						<td><?php echo $arr['WorkId'] ?></td>
						<td><?php echo $arr['Name'] ?></td>
						<td><?php echo $arr['Status'] == 1 ? '显示' : '隐藏' ?></td>
						<td><?php echo $arr['Type'] == 1 ? '首页作品' : '汇总攻略' ?></td>
						<td><?php echo date('Y-m-d H:i:s', $arr['CreateTime']) ?></td>
						<td><?php echo date('Y-m-d H:i:s', $arr['UpdateTime']) ?></td>
						<td>
							<a href="javascript:;" onclick="del(<?php echo $arr['WorkId'] ?>)" class="btn">删除</a>
							<a href="/Work/Edit?id=<?php echo $arr['WorkId'] ?>" class="btn">修改</a>
						</td>
					</tr>
					<?php } ?>
				</table>
				<?php \Controller\UC\Pager::instance()->run(array('pager' => $pager)) ?>
			</div>
		</div>
	</div>
<?php $this->import('Footer') ?>
<script>
function del(id) {
	if (confirm('确定要删除这篇作品吗？')) {
		$.ajax({
			url: '/Ajax/Work/Del',
			data: {id:id},
			dataType: 'json',
			success: function(data) {
				if (data.error) {
					alert(data.data);
				} else {
					window.location.reload();
				}
			}
		});
	}
}
</script>